# python模块
import sys
# 第一种: 在 import my_test 之前，
#    将/opt/mylibs 添加到 sys.path 所指代的列表中(临时修改)
# sys.path.append("/opt/mylibs")

# 第二种：临时修改环境变量(终端运行py脚本)
# [root@localhost day08]# python3 demo03_module.py
# Traceback (most recent call last):
#   File "demo03_module.py", line 9, in <module>
#     import my_test
# ModuleNotFoundError: No module named 'my_test'
# [root@localhost day08]# export PYTHONPATH=/opt/mylibs
# [root@localhost day08]# python3 demo03_module.py
# my_test~

import my_test
my_test.func01()
# 1. mkdir /opt/mylibs
# 2. cd /opt/mylibs
# 3. vim my_test.py
#    def func01():
#        print("my_test~")
print("path:", sys.path)  # sys.path

# 模块导入的方式
# import 模块名
# from day07 import xxx
# from day07 import *  # 导入day07下的所有模块，*表示所有

# 注意
# import shutil  # 避免自定义的模块与已知模块崇重名


# 导入模块心路历程:
#       会从sys.path所指向的列表中的元素一个一个路径去配，
#       如果能匹配的上，则表示导入成功，停止后续的匹配
#       搜索不到表示导入失败，
# ['/root/PycharmProjects/NSD2110/day08',
#  '/root/PycharmProjects/NSD2110',
#  '/root/3/pycharm/pycharm-2020.1.1/plugins/python/helpers/pycharm_display',
#  '/usr/lib64/python36.zip',
#  '/usr/lib64/python3.6',
#  '/usr/lib64/python3.6/lib-dynload',
#  '/usr/lib64/python3.6/site-packages',
#  '/usr/lib/python3.6/site-packages',
#  '/root/3/pycharm/pycharm-2020.1.1/plugins/python/helpers/pycharm_matplotlib_backend']

